// components/discountsInfo/discountsInfo.js
import api from "../../api/index";
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    info: {
      type: Object,
      value: () => {
        return {};
      },
    },
    isBtn: {
      type: Boolean,
      value: true,
    },
    isDetailbtn: {
      type: Boolean,
      value: true,
    },
  },

  /**
   * 组件的初始数据
   */
  data: {},

  /**
   * 组件的方法列表
   */
  methods: {
    closeQrCode() {
      this.setData({
        qrCodeShow: false,
      });
    },
    getQrcode() {
      api
        .apiStoreCouponQrcode({
          coupon_id: this.data.info.coupon_id,
        })
        .then((res) => {
          this.setData({
            qrcodeQuery: {
              show: {
                title: "优惠券领取码",
                button: "保存到相册",
                explain: "扫码领取优惠券",
                ...res.data,
              },
              download: res.data.qrcode,
            },
            qrCodeShow: true,
          });
        });
    },
    goTo(e) {
      let { url, id } = e.currentTarget.dataset;
      wx.navigateTo({
        url: `${url}?id=${id}`,
      });
    },
  },
});
